<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>加减计数器</title>
    <link href="./index.css" rel="stylesheet" />
</head>
<body>
    <!-- 1.html结构 -->
    <div id="app">
        <!-- 计数器功能区域 -->
        <div class="input-num">
            <!-- 减 -->
            <button @click="decrement">-</button>
            <!-- 数值 -->
            <span>{{ count }}</span>
            <!-- 加 -->
            <button @click="increment">+</button>
        </div>
    </div>
     
    <!-- 2.开发环境版本，包含了有帮助的命令行警告 -->
    <script src="../js/vue.js"></script>
     
    <!-- 3.创建Vue实例 -->
    <script>
        var app = new Vue({
            el: "#app", // 挂载点
            data: {
                count: 0 // 初始计数值
            },
            methods: {
                increment() {
                    if (this.count < 10) { // 限制最大值
                        this.count++;
                    }
                },
                decrement() {
                    if (this.count > 0) {//限制最小值
                        this.count--; 自减
                    }
                    
                }
            }
        });
    </script>
</body>
</html>